const fs = require('fs');
const path = require('path');
const package = require('../package');
const defaultConfig = require('./default');

const ENVIRONMENT = process.env.NODE_ENV;
const prod = ENVIRONMENT === 'production';

defaultConfig.namespace = package.name

let config = defaultConfig;

if (fs.existsSync(path.resolve(__dirname, 'config.prod.js')) && prod) {
    config = Object.assign(defaultConfig, require('./config.prod'));
} else if (fs.existsSync(path.resolve(__dirname, 'config.local.js'))) {
    config = Object.assign(defaultConfig, require('./config.local'));
}

module.exports = config;